package com.lianzai.mobile.controller;

import com.lianzai.common.config.WxConfig;
import com.lianzai.common.constant.Constant;
import com.lianzai.common.utils.R;
import com.lianzai.common.utils.jackson.Json;
import com.lianzai.mobile.domain.PayOrderDto;
import com.lianzai.payment.service.OrderInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

/**
 * 订单首页
 * @author zb
 * @email 1106900429@qq.com
 * @date 2018-10-29 10:50:29
 */
@Slf4j
@Controller
@RequestMapping("/mobile/orderIndex")
public class OrderInfoController {
	@Autowired
	private OrderInfoService orderInfoService;

	@Autowired
	private WxConfig wxConfig;

	@Value("${server.domain-index}")
	private String index;

	@Autowired
	private Json json;

	@GetMapping()
	public ModelAndView orderIndex(HttpServletRequest request, Model model){
//		if(StringUtils.isEmpty(code)){
//			String url = WxUtil.connectOauth2Authorize(wxConfig.getAppid(), index);
//			return new ModelAndView(new RedirectView(url));
//		} else {
//			log.info("进入订单页 code:{}", code);
//			JSONObject json = WxUtil.getOpenIdByJsCode(code, wxConfig.getAppid(), wxConfig.getAppsecret());
//			log.info("获取openId响应参数:{}", json.toString());
//			model.addAttribute("openid", json.get("openid"));
//			return new ModelAndView("mobile/order");
//		}

		model.addAttribute("openid", request.getSession().getAttribute(Constant.CURR_OPEN_ID));
		return new ModelAndView("mobile/order");
	}



}
